Well, I decided to upgrade bob and add the feature of multiple modes. The idea is, that there are two modes. The first mode attaches bob to the player, the second mode detaches bob from the player wherever the mode was activated. All you have to do is press the activate button again after you have engaged mode one. But for some reason, the cog is running the modes at the same time and creating and destroying bob in one swift run of the script. here's what I have:
I know that bob is being run, because I hear the drop sound in mode 2 (if(mode == 1); statement). So what did I do wrong? I'd imagine that the script is changeing the mode and moving on to the next if statement before I press the activate button again. How do I fix this?
------------------
Those who stare in the eyes of death and laugh will be the first to go.
Code:
# Jedi Knight Cog Script # # bob.COG # # bob the cog does his best to bring justice to those deserving a terrible terrible death that involves many pointy objects! # # # This Cog is Not supported by LucasArts Entertainment Co symbols model bobmod=remo.3do local thing bob local thing player local thing victim local sector playersector local sound bobshoot=ricochet03.wav local sound dropbob=droidbody2.wav local template bobtemp=ghost local template projectile1=+bryarbolt local int mode local vector playerpos local vector victimpos local vector playerposa local vector bobpos local message startup message activated message pulse end # ======================================================================================== code startup: player = GetLocalPlayerThing(); mode = 0; return; activated: if(mode == 0) { playersector = GetThingSector(player); playerpos = GetThingPos(player); bobpos = VectorAdd(playerpos,'0 0 0.1'); bob = CreateThingatPos(bobtemp,playersector,bobpos,'0 0 0'); SetThingModel(bob,bobmod); AttachThingToThingEx(bob,player,0x8); SetPulse(.05); mode = 1; } if(mode == 1) { bobpos = GetThingPos(bob); DetachThing(bob); PlaySoundPos(dropbob,bobpos,8,0,3,0x80); mode = 2; } if(mode == 2) { DestroyThing(bob); SetPulse(0); mode = 0; } return; pulse: victim = FirstThingInView(bob,180,6,0x404); while(victim != -1) { if( HasLos(bob,victim) && (victim != player) ) { victimpos = VectorSub(GetThingPos(victim),GetThingPos(bob)); SetThingLook(bob,victimpos); FireProjectile(bob,projectile1,bobshoot,8,'0 0 0','0 0 0',1.0,0,0,0); } victim = NextThingInView(); } return; # ........................................................................................ end
I know that bob is being run, because I hear the drop sound in mode 2 (if(mode == 1); statement). So what did I do wrong? I'd imagine that the script is changeing the mode and moving on to the next if statement before I press the activate button again. How do 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.