I've been working on a monster mostly in the last couple of days, however, I found a fatal flaw with it. You can probably guess by the title, but before I explain, I should note that the gimmick of this monster is that they're most effective in groups. While one can hardly do anything, 5+ can be deadly when all are attacking one thing. When you stand on them however, only one is able to attack you at a time, due to the range of the attacks and the enemies bboxes blocking each other. Sometimes one can't even manage to attack you. Increasing the range of the attacks doesn't help at all. They have a tendency to stand on each other, but the problem persists even when changing the bboxes so they can't stand on each other. The scripts in case you need 'em, only these two are required for it to run. Sounds will probably only work in the alpha build because of $get_random_token(). You will need this model in order for this script to work:
https://www.dropbox.com/s/lgc4q7crntkwhl0/chumtoad.mdl?dl=1
Put in msc/models/monsters.
Chumtoad:
Attack Multiplier Stacker:
How should I fix this? Is there a way to make attacks go through entities of the same name/script? Should I make them flee for 1 second if the player is significantly higher enough than the chumtoad? Should I add an ability to throw the player off the chumtoad? Or perhaps a different solution?
https://www.dropbox.com/s/lgc4q7crntkwhl0/chumtoad.mdl?dl=1
Put in msc/models/monsters.
Chumtoad:
Code:
//Chumtoad by greatguys1
//This doens't follow the original concept of it from hl1 what-so-ever.
//The idea is to have it like "zerg" where they're most effective in numbers, having damage scale higher the more it attacks, and even more when more are attacking the same target.
#scope server
{
//Settings for base monster new
setvar ANIM_RUN "hop_1"
setvar ANIM_WALK "hop_1"
setvar ANIM_IDLE "idle"
setvard ANIM_ATTACK "flinch2"
setvard NPC_NO_ATTACK 0
setvard ATTACK_MOVERANGE 10
setvard ATTACK_RANGE 50
setvard ATTACK_HITRANGE 60
const ATTACK_HITCHANCE 80
const FLEE_HEALTH 0
const FLEE_CHANCE 0
setvard CANT_FLEE 1
setvard CAN_RETALIATE 1
setvard CAN_FLINCH 0
//damage_stack_mult
const STACK_DAMAGE_SCRIPT "test_scripts/damage_stack_mult"
const STACK_PARAM2 5
const STACK_PARAM3 0.1
const STACK_PARAM4 10
//Custom Blink cycle //If anyone wants to add a blink cycle to the other skins, I'll gladly accomondate it here
const BLINK_FREQ 5
const BLINK_DUR 0.2 //For each step
setvard BLINK_STEP 0
const BLINK_MAX 2 //Two other than the idle, eye open state.
setvard BLINK_CYCLE 1 //1 for up, -1 for down
//Suicide chances
const SUICIDE_CHANCE 100 //% chance
const SUICIDE_THRESHOLD 0.7 //Multiplier of what health I need to be under before I check against chance to explode
const SUICIDE_DISTANCE 100 //Distance affected by explosion
setvard SUICIDING 0
setvard TRIED_SUICIDE 0
//Other stuff particular to this script
const ANIM_CHARGE "idle2"
const ANIM_SUICIDE "flinch1"
setvard ANIM_IDLE3_CHANCE 5 //% chance to use the idle3 animation, slower but more damage
const LONG_ATTACK $rand(50,60) //Not long range, but taking longer to strike.
const SHORT_ATTACK $rand(10,20)
const MONSTER_HEALTH $get(ent_me,maxhp) //I think this'll grab it again should it change.
const GIB_BURSTER_SCRIPT "effects/sfx_gib_burst_alien"
const GIB_BURSTER_FORCE 300
const EXPLOSION_SFX "effects/sfx_sprite"
const EXPLOSION_SPRITE "oculus/exp_green.spr"
const EXPLOSION_SFX_SOUND "monsters/tube/Tube_ExplodingDeath.wav"
const DEATH_SOUNDS "monsters/bat/pain1.wav;monsters/bat/pain2.wav;monsters/beetle/idle.wav2;monsters/beetle/idle3.wav"
const IDLE_SOUNDS "monsters/ogre_welp/bc_idle2.wav;monsters/ogre_welp/bc_idle3.wav;monsters/ogre_welp/bc_idle4.wav"
const PAIN_SOUNDS "monsters/ogre_welp/bc_pain1.wav;monsters/ogre_welp/bc_pain2.wav;monsters/ogre_welp/bc_pain3.wav"
const PAIN_SOUND_RATE 100 //percent chance to play pain sound
const HIT_SOUNDS "monsters/tube/TubeCritter_Hit1.wav;monsters/tube/TuberCritter_Hit2.wav;monsters/tube/TubeCritter_Hit3.wav"
const HIT_SOUND_RATE 100 //percent chance to play hit sound
}
#include monsters/base_monster_new
#include test_scripts/monster_explode
{ game_precache
precache monsters/chumtoad.mdl
precache EXPLOSION_SPRITE
precache agibs.mdl
}
{ npc_spawn
name "a|Chumtoad"
race vermin
hp 300
setmodel "monsters/chumtoad.mdl"
width 20
height 20
setmoveanim ANIM_RUN
setidleanim ANIM_IDLE
blood green
roam 0
//setvard MONSTER_HEALTH $get(ent_me,hp)
setvard SOUND_CHANNEL $rand(0,100) //I dunno what the max is
callevent BLINK_FREQ do_blinking
}
//{ cycle_down
// playanim loop ANIM_IDLE
//}
{ do_blinking
local L_PROPS $get(ent_me,renderprops)
local L_SKIN $get_token(L_PROPS,4)
setvard BLINK_STEP $math(add,BLINK_STEP,BLINK_CYCLE)
if ( BLINK_STEP >= BLINK_MAX )
{
setvard BLINK_CYCLE -1
}
else if ( BLINK_STEP <= 0 )
{
setvard BLINK_CYCLE 1
}
if ( L_SKIN < 3 )
{
setprop ent_me skin BLINK_STEP
}
if ( BLINK_STEP == 0 )
{
callevent BLINK_FREQ do_blinking
}
else
{
callevent BLINK_DUR do_blinking
}
}
{ game_damaged
local L_HP $get(ent_me,hp)
if ( L_HP <= $math(multiply,MONSTER_HEALTH,SUICIDE_THRESHOLD) )
{
if ( !TRIED_SUICIDE )
{
setvard TRIED_SUICIDE 1
if ( $func(func_test_chance,SUICIDE_CHANCE) )
{
callevent do_suicide_charge
}
}
}
if ( $func(func_test_chance,PAIN_SOUND_RATE) )
{
playsound SOUND_CHANNEL 10 $get_random_token(PAIN_SOUNDS)
}
return **clear
returndata 1 //A bug exists that a $func within one of these functions will overwrite the returndata. Resetting it.
}
{ game_damaged_other //PARAM1=target_hit PARAM2=dmg PARAM3=dmg_type //items return <attack_callback>_damaged_other
local L_TARGET PARAM1
applyeffect L_TARGET STACK_DAMAGE_SCRIPT $get(ent_me,name) STACK_PARAM2 STACK_PARAM3 STACK_PARAM4
if ( $func(func_test_chance,HIT_SOUND_RATE) )
{
playsound SOUND_CHANNEL 10 $get_random_token(HIT_SOUNDS)
}
return **clear
returndata 1 //A bug exists that a $func within one of these functions will overwrite the returndata. Resetting it.
}
{ game_death
playsound SOUND_CHANNEL 10 $get_random_token(DEATH_SOUNDS)
}
{ do_suicide_charge
callevent npcatk_suspend_ai
playanim critical ANIM_CHARGE
setvard SUICIDING 1
}
{ finish_charge //Called from the model
playanim critical ANIM_SUICIDE
}
{ finish_suicide //Called from the model
setprop ent_me rendermode 5
setprop ent_me renderamt 0
callevent do_explode
callevent npc_suicide
}
{ do_explode
local L_VEC $get(ent_me,origin)
vectoradd L_VEC $vec(0,0,30)
local L_COL $clcol(0,0,0)
local L_STR "0;3;255;add;"
stradd L_STR L_COL
stradd L_STR ";20;10"
clientevent new all EXPLOSION_SFX L_VEC EXPLOSION_SPRITE L_STR 0.5
clientevent new all GIB_BURSTER_SCRIPT L_VEC GIB_BURSTER_FORCE
playsound 0 10 EXPLOSION_SFX_SOUND
}
{ npc_selectattack
if ( $rand(0,100) <= ANIM_IDLE3_CHANCE )
{
setvard ANIM_ATTACK idle3
}
else
{
setvard ANIM_ATTACK flinch2
}
}
{ attack_1 //Called from the model
callevent npcatk_dodamage NPCATK_TARGET ATTACK_HITRANGE LONG_ATTACK ATTACK_HITCHANCE pierce
}
{ attack_2 //Called from the model
callevent npcatk_dodamage NPCATK_TARGET ATTACK_HITRANGE SHORT_ATTACK ATTACK_HITCHANCE pierce
}
{ func_test_chance //Returns 1 on a win, 0 on fail. PARAM1 = % to win
local L_CHANCE PARAM1
local L_ROLL $rand(1,100)
if ( L_ROLL <= L_CHANCE )
{
return 1
}
else
{
return 0
}
}
Attack Multiplier Stacker:
Code:
//Increasing damage from the same monster / same type of monster via a multiplier. Originally built for the chumtoad. By greatguys1
//If you can think of a better name that best describes what this does, please change it, as the current name is inaccurate/confusing.
//I'm not using the effect_base as it doesn't seem to have anything that would pertain to this.
//Accepts params:
//1; Creature name
//2; Expire time
//3; multiplier increment factor
//4; max multiplier
#scope server
{
const CHECK_STACK_TIME 1 //Will always check at one second increments
setvard CUR_MULT 1
setvard ACTIVATED 0
setvard DAMAGED_THIS_TICK 0
setvard TICKS_NOT_DAMAGED 0
}
{ game_precache
local L_ID "stack_damage"
setvard reg.effect.name L_ID
setvard reg.effect.id L_ID
setvard reg.effect.flags "nostack"
setvard reg.effect.script $currentscript
setvard game.effect.removeondeath 1
setvard game.effect.id L_ID
setvard game.effect.displayname "Zerg Swarm Debuff"
setvard game.effect.flags "nostack"
setvard game.effect.type "nostack"
registereffect
}
{ game_activate //PARAM1 = creature name, not full PARAM2 = expire time
setvard CREATURE_STACK_NAME PARAM1
setvard EXPIRE_TIME PARAM2
setvard INCREMENT_FACTOR PARAM3
setvard MAX_MULT PARAM4
setvard ACTIVATED 1
callevent check_stack
}
{ check_stack
if ( ACTIVATED )
{
if ( !DAMAGED_THIS_FRAME )
{
setvard TICKS_NOT_DAMAGED $math(add,TICKS_NOT_DAMAGED,1)
if ( TICKS_NOT_DAMAGED == EXPIRE_TIME )
{
callevent effect_die
}
}
else
{
setvard TICKS_NOT_DAMAGED 0
setvard DAMAGED_THIS_FRAME 0
}
}
callevent CHECK_STACK_TIME check_stack
}
{ game_damaged //PARAM1=attacker PARAM2=dmg PARAM3=dmg_type PARAM4=accuracy_roll PARAM5=skill PARAM6=Inflicter
if ( ACTIVATED )
{
local L_ATTACKER PARAM1
if ( CREATURE_STACK_NAME contains $get(L_ATTACKER,name) )
{
local L_DAMAGE PARAM2
setvard CUR_MULT $math(add,CUR_MULT,INCREMENT_FACTOR)
if ( CUR_MULT > MAX_MULT ) //I can't find the clamp command
{
setvard CUR_MULT MAX_MULT
}
local L_DAMAGE $math(multiply,L_DAMAGE,CUR_MULT)
returndata CUR_MULT
//setdmg dmg L_DAMAGE
setvard DAMAGED_THIS_FRAME 1
}
}
}
{ game_death
callevent effect_die
}
{ effect_die
removescript
}
//{ game_duplicated
//
// callevent effect_die
//}
How should I fix this? Is there a way to make attacks go through entities of the same name/script? Should I make them flee for 1 second if the player is significantly higher enough than the chumtoad? Should I add an ability to throw the player off the chumtoad? Or perhaps a different solution?
Last edited: