Cool Pog Tricks

More
21 years 6 months ago #3104 by SoupDragon
Replied by SoupDragon on topic Cool Pog Tricks
You can have FTP access to the the pogfiles directories. Drop me an email.

Please Log in or Create an account to join the conversation.

More
21 years 6 months ago #3118 by Mehrunes
Replied by Mehrunes on topic Cool Pog Tricks

Originally posted by Flamineo
Do death scripts require a hisim? Maybe you can't cast icBullet to hisim? Probably not that simple: I had thought all hsims could be cast to hisims.

[edit]Oops.

Another behaviour of sets and lists, specifically when using them as globals or object properties:

Code:
[i]don't work[/i] hobject thing = Sim.Create("ini:/thing"); Set.Add(Global.Set("things"), thing); [i]works[/i] hobject thing = Sim.Create("ini:/thing"); set things = Global.Set("things"); Set.Add(things, thing); Global.SetSet("things", things);
Not sure why. The working version ought to be atomic{} if more than one process might try to do it at once.
[/edit]


Many scripting languages seem to have numerous minor problems like this. I'm more worried about Gramps example. GrandpaTrout, did you try putting the whole statement into parentheses? Or using variables to hold the two constants?

Please Log in or Create an account to join the conversation.

More
21 years 6 months ago #3120 by GrandpaTrout
Replied by GrandpaTrout on topic Cool Pog Tricks
The addition/subtraction bug? Don't remember that was back in May. Haarg hit the same problem. You can find his comments in the location finder code. Its easy to avoid. You just need to know.

-Gtrout

Please Log in or Create an account to join the conversation.

More
21 years 6 months ago #3139 by MajorTom
Replied by MajorTom on topic Cool Pog Tricks

Originally posted by GrandpaTrout



Some #2 items. I have not been able to get deathscripts to work with PBC bolt objects. They do work with REM missiles, but sometimes the player gets trapped with the dead sim. Cargo pods become targetable subsims when you child attach them to a ship. Countermeasure flares do not become targetable. Some can be fixed immobile. Some cannot. I will dig up a list of Object types. We can try to fill in the behavior. (like a group crossword!)


-Gtrout


Were you actually trying to get a bolt to go through a deathscript??
why would one want that?

Here is the way I handle Deathscripts for example:
Code:
//when I create the sim I add the function I want called Object.SetStringProperty( guard_bot, "death_script", "<my package>.ObjectDeath" ); // then I do the function like this for example task ObjectDeath( hsim sim ) { hship last_attacker; string message, object_name; htask delay; int frag_value; int dropit; hfaction aggressor_faction, object_faction; hship player=iShip.FindPlayerShip(); hsim bomb; atomic { object_faction = iSim.Faction( iSim.Cast(sim) ); last_attacker = iShip.Cast( iSim.LastAttacker(iSim.Cast(sim)) ); aggressor_faction = iSim.Faction( last_attacker ); object_name= Object.StringProperty( sim, "name" ); // update the score of out attacker ( increment by frag_value ) if ( iSim.Type(sim) == T_CargoPod ) { // play around with different results of killing a pod dropit = Math.RandomInt(1, 5); if ( aggressor_faction != object_faction ) { roMPUtils.increment_frags ( last_attacker, roMPUtils.get_frag_value(sim) ); } else roMPUtils.decrement_frags ( last_attacker, roMPUtils.get_frag_value(sim) ); // give the lucky player a health power up if (dropit <= 3 ) roMPUtils.SpawnKilledPodPowerUps (sim); else //blow him up with AM { message = iMPUtils.MakeDeathMessage( last_attacker, sim ); //delay = start roMPUtils.delay_broadcast_message( sim, message, BMT_Event, 2.0 ); bomb = Sim.Create ( "ini:/sims/8km_am_explosion_wr", "big Big" ); Sim.PlaceAt ( bomb, sim ); start iDeathScript.Explosives( iSim.Cast(sim) ); Sim.Destroy( iSim.Cast(sim) ); //Task.Detach( delay ); return; } } else { if (aggressor_faction == iFaction.Find(Text.Field("mp_flag_team_a", FT_Text))) { if (String.Left(object_name ,4) == "Beta" || object_faction == iFaction.Find(Text.Field("mp_flag_team_b", FT_Text))) { roMPUtils.increment_frags ( last_attacker, roMPUtils.get_frag_value(sim) ); } else roMPUtils.decrement_frags ( last_attacker, roMPUtils.get_frag_value(sim) ); } if (aggressor_faction == iFaction.Find(Text.Field("mp_flag_team_b", FT_Text))) { if (String.Left(object_name ,5) == "Alpha" || object_faction == iFaction.Find(Text.Field("mp_flag_team_b", FT_Text))) { roMPUtils.increment_frags ( last_attacker, roMPUtils.get_frag_value(sim) ); } else roMPUtils.decrement_frags ( last_attacker, roMPUtils.get_frag_value(sim) ); } } // tell everyone about it message = iMPUtils.MakeDeathMessage( last_attacker, sim ); delay = start roMPUtils.delay_broadcast_message( sim, message, BMT_Event, 2.0 ); if ( object_name == "Gunstar 8ty8" ) { if (object_faction == iFaction.Find(Text.Field("mp_flag_team_b", FT_Text))) //send a message that one can be re-deployed ServerOnUserMessage( 154, last_attacker, none, " Beta Gunstar destroyed" ); else ServerOnUserMessage( 156, last_attacker, none, "Alpha Gunstar destroyed" ); bomb = Sim.Create ( "ini:/sims/1_5km_am_explosion_wr", "Lil Bigi" ); Sim.PlaceAt ( bomb, sim ); start iDeathScript.Explosives( iSim.Cast(sim) ); Sim.Destroy( iSim.Cast(sim) ); //Task.Detach( delay ); return; } start iDeathScript.Explosives( iSim.Cast(sim) ); Sim.Destroy( iSim.Cast(sim) ); Task.Detach( delay ); } } //ObjectDeath
Note:The actual explosion of the sim itself comes from iDeathScript.Explosives and as far as I can tell that is also the function that makes the target assistant jump immediatly to the next target (reset the Hud sensor list?) without waiting for the sim that was killed to disappear

as you see I have different sim types going through the function and do all kinds of different stuff with em.


Edit: sorry the script got hard to read, I forget to close my code entry with /code

EOC/IWar2 Multiplayer Fansite

Please Log in or Create an account to join the conversation.

More
21 years 6 months ago #3178 by Flamineo
Replied by Flamineo on topic Cool Pog Tricks
Well, this was fun to track down. Can anyone get Lock.Find() to return none for a non-existent lock object, rather than crashing Flux with no error message? I've tried a few configurations, with and without their own task context, and I can't.

Only obvious workaround that springs to mind:
Code:
atomic { obj_lock = Lock.Create(lock_name); if(obj_lock == none) return Lock.Find(lock_name); } return obj_lock;

If anyone can see a fix for this, please shout. If 2 or more others confirm the bug, it can join the other gotchas for future reference.

Please Log in or Create an account to join the conversation.

More
21 years 6 months ago #3203 by GrandpaTrout
Replied by GrandpaTrout on topic Cool Pog Tricks
This is tough question week for you! :D

I have never used locks. I just use global booleans inside atomic statements. They are fast and tested. You may have already seen this, but just in case:

// Grab lock

atomic {
if (false == Global.Bool("myLock")){
// lock is clear, so grab it.
Global.SetBool("myLock",true);
}else {
// lock is held, so return.
return;
}
}// end atomic.

// Release Lock at end of use.

atomic {
Global.SetBool("myLock", false);
}

-Gtrout

Please Log in or Create an account to join the conversation.