I'm currently learning the ropes of cog so I decided to make a simple AI character. He's supposed to follow me around and when I get damaged, run after the ph00l who shot me. The problem is that he pays no attention to me getting hurt. here's the code:
How the hecktic henry odule can I fix this?
------------------
Those who stare in the eyes of death and laugh will be the first to go.
Code:
symbols model newmodel=kyg7.3do local model weaponMesh=cong.3do local sound activsound=i09ky01z.wav local template base=walkplayer local template shot=+concbullet local flex timactive=1 local flex isdamaged=1 local message activated message pulse message damaged end code activated: if (timactive == 2) { DestroyThing(littletim); SetPulse(0); timactive = 1; return; } if (timactive == 1) { player = GetSourceRef(); littletim = FireProjectile(player, base, activsound, 18, '0.07 0.07 0.00', '0 0 0', 1.0, 0x20, 0, 0); SetThingFlags(littletim, 0x300); SetThingModel(littletim, newmodel); jkSetWeaponMesh(littletim, weaponMesh); SetPulse(.01); SyncThingPos(littletim); timactive = 2; return; } pulse: if (isdamaged == 1) { playerface = VectorSub(GetThingPos(player), GetThingPos(littletim)); SetThingLook(littletim, playerface); playerdir = VectorScale(VectorNorm(VectorSub(GetThingPos(player), GetThingPos(littletim))), 5); ApplyForce(littletim, playerdir); return; } if (isdamaged == 2) { if (damageguy == -1){ isdamaged = 1; return; } face = VectorSub(GetThingPos(damageguy), GetThingPos(littletim)); SetThingLook(littletim, face); dir = VectorScale(VectorNorm(VectorSub(GetThingPos(damageguy), GetThingPos(littletim))), 5); ApplyForce(littletim, dir); return; } return; damaged: damageguy = GetSourceRef(); isdamaged = 2; return; end
How the hecktic henry odule can I fix this?
------------------
Those who stare in the eyes of death and laugh will be the first to go.
Those who stare in the eyes of death and laugh will be the first to go.