• Welcome to Battlezone Universe.
 

News:

Welcome to the BZU Archive dated December 24, 2009. Topics and posts are in read-only mode. Those with accounts will be able to login and browse anything the account had access granted to at the time. No changes to permissions will be made to be given access to particular content. If you have any questions, please reach out to squirrelof09/Rapazzini.

Main Menu

Spinoff: Uncle Avatar's Scriptor, C++ and Python Time...

Started by General BlackDragon, April 23, 2008, 06:03:45 PM

Previous topic - Next topic

General BlackDragon

neato. Wonder when you'll teach us C++ mp dll basics? :D



*****General BlackDragon*****

Sonic

Quote from: General BlackDragon on April 23, 2008, 06:03:45 PM
neato. Wonder when you'll teach us C++ mp dll basics? :D

C++ can be more difficult than the scriptor, but can also be more fun. Kudos if you can figure out what this does:

void instantMission::SendPKs(bool IsSetup, bool bTaunt)
{
  Handle hPlayer;

  if(IsSetup) { // Set things up
    Vector NewPos;
    for(i=0;i<MAX_TEAMS;i++) {
      hPlayer=GetPlayerHandle(i);
      if(hPlayer) { // FURY PK ATTACK!
        if(IsAround(hndPK[i])) {
          SetCurHealth(hndPK[i],GetMaxHealth(hndPK[i]));
          SetCurAmmo(hndPK[i],GetMaxAmmo(hndPK[i]));
          Attack(hndPK[i],hPlayer);
        } else {
          NewPos=GetPositionNear(EnemyRecyPos,75.0f,150.f);
          hndPK[i]=BuildObject("fvsavmmpk",comp_team,NewPos);
          Attack(hndPK[i],hPlayer);
          PKs++;
        }
      }
    }
    if(bTaunt)
      DoTaunt(TAUNTS_PK);
  } else { // If PK is around, retarget to Player
    for(i=0;i<MAX_TEAMS;i++) {
      if(IsAround(hndPK[i])) {
        hPlayer=GetPlayerHandle(i);
        Attack(hndPK[i],hPlayer);
      }
    }
  }
}


(Out of curosity, but anyone know how to convert that to DLL Scriptor for the hell of it? :P)
"Linux is user friendly...
...it's just very selective about who its friends are."

Red Devil

I "know" C++, but I don't know the Scriptor.

It picks on the players in a not-nice way.  AIP's can do the same thing.   :wink:
What box???

bigbadbogie

y...eah -- ill stick with the scriptor *bites fist*
Others would merely say it was good humour.


My BZ2 mods:

QF2: Essence to a Thief - Development is underway.

Fleshstorm 2: The Harvest - Released on the 6th of November 2009. Got to www.bz2md.com for details.

QF Mod - My first mod, finished over a year ago. It can be found on BZ2MD.com

General BlackDragon

That looks like it has something to do with a fury attacking the player... :evil:



*****General BlackDragon*****

Red Devil

Don't sell yourselves short, guys.

Quote from: bigbadbogie on April 23, 2008, 07:09:10 PM
y...eah -- ill stick with the scriptor *bites fist*
What box???

bigbadbogie

you'd need an iq of 150 to understand any of that
Others would merely say it was good humour.


My BZ2 mods:

QF2: Essence to a Thief - Development is underway.

Fleshstorm 2: The Harvest - Released on the 6th of November 2009. Got to www.bz2md.com for details.

QF Mod - My first mod, finished over a year ago. It can be found on BZ2MD.com

Nielk1

Maybe I should Make a "Stalker Nielk1's DLL Time..."
Then again, I've only made test DLLs so far, nothing mutch else. (no time)

Click on the image...

OvermindDL1

Well Sonic, I do not know about the scriptor, but in python that direct translation would be:
def SendPKs(IsSetup, bTaunt): # Wouldn't it be better if these two arguments were part of the class, not something to be passed in?

if IsSetup: # Set things up
for i in range(MAX_TEAMS):
hPlayer = GetPlayerHandle(i)
if hPlayer:
if self.hndPK[i]: # I have bool overloaded to do IsAlive2
self.hndPK[i].SetCurHealth(self.hndPK[i].GetmaxHealth())
self.hndPK[i].SetCurAmmo(self.hndPK[i].GetMaxAmmo())
self.hndPK[i].Attack(hPlayer)
else:
NewPos = self.EnemyRecyPos.GetPositionNear(75.0, 150.0)
self.hndPK[i] = BuildObject("fvsavmmpk", self.comp_team, NewPos)
self.hndPK[i].Attack(hPlayer)
self.PKs++
if bTaunt:
DoTaunt(TAUNTS_PK)
else: # If PK is around, retarget to Player
for i in range(MAX_TEAMS):
if self.hndPK[i]:
hPlayer = GetPlayerHandle(i)
self.hndPK[i].Attack(hPlayer) # Shouldn't you test that hPlayer exists first, or you could just inline the GetPlayerHandle call...


Although when in python I would recode it vastly differently...

Generated by OvermindDL1's Signature Auto-Add Script via GreaseMonkey


GreenHeart

While your on the topic of scripting i'd like to ask for some help on some code that has been giving some problems.  I have a routine where the construction rig is created if he don't already exist & then i'd like to order him to build certain objects possibly at specified paths. so far the rig has ignored everything i've tried.  I've been trying to get this portion to work so i can setup a new map with a second team allied to the other cpu team but it seems to get ignored. Below is the working code i have so far without the non-working code.

void instantMission::ExtraCPUTEAM()
{

m_erigCounter++;
if((m_erigCounter % (20 * m_GameTPS))==0)
{
if(!IsAround(m_erig))
{
m_erig=BuildObject("ivcons", m_SecondCompTeam, "Recycler");

SetIndependence(m_erig, low);
//AddToMessagesBox("UnitCreation: ivcons");
PrintConsoleMessage("UnitCreation: ivcons");
m_HaveRig=true;
}
Signature:
Many failures will take place in the process of attempting to achive your goal. It don't matter how many times you fail, Its how much you've learned each time since its apart of the learning process.

Avatar

Um, to keep the  :-o factor down maybe you guys could take the python/C++ coding to another thread?  This is "Introduction to Simple Scripting", to help new SP mission makers get started, and you might scare them off.

And Sonic's routine sent Furies after PK...  wonder how he's doing?  Many of the old gang have wandered off, probably due to Alzheimers...  :)

Thanks...

-Av-

Sonic

Sorry, we like to toss out code to see the reaction from the new guys. Issue with my code that I relized after I posted it was the Scriptor only reconizes one player, my code is multi-player. But still, it would be fun to convert it to other codes just to point out the pros and cons of each item. I still believe those wanting fast, easy and not to complex mission scripts to use the scriptor.

Oh, and the code is sending Furies named "PKs" after the players if certain events is triggered. Than every 10 seconds, the game re-runs the code to tell the Furies that are out to hunt the player. Very fun to watch your teammates bet blasted into the air and find a fury following them to the ends of the earth. >:D

Edit:
Split the topic so Avatar's topic can stay out of the :o factor.

GreenHeart: If you send me a PM with the link to your actual code (all of it) with a detailed description of what you are trying to do, I can take a look and give you my thoughts on what might be going wrong.
"Linux is user friendly...
...it's just very selective about who its friends are."

Avatar

Thanks, I appreciate it.

I think the natural progression is like me...  I started out with the Scriptor, then moved to C++.  With help from the Community neither one is impossible to learn, despite much of it looking pretty scary when you're first starting out.  That's the big thing, is not to get discouraged because what you're looking at is GREEK...  it'll all come a bit at a time if you just keep plugging away, ask for help when needed, and don't give up...

And I agree completely, other than the "fast, easy, and not too complex" part...  for SP missions I don't think you'll find anything you can't do with Scriptor simple because of the limitations of most SP missions.  They usually all boil down to a few basic mission types, and the Scriptor has more than enough firepower to do pretty much anything.

MP is the 'new frontier', and I'm very interested in OM's python based scripter for that as it could open up some very cool possibilities for MP play when enough creative people learn how to use it.  OTOH it looks like quite a few of us are getting comfortable with C++ and Nathan's been great at handing out DLL updates and sample code as well as advice...   very cool.

-Av-

Sonic

Don't forget with the scriptor, you can come up with a hybrid of C++ and Scriptor code. The source code for the scriptor's dll is available and can be tweeked. If you have functions that are common for you (say look for a pod x being built than do this..that...then this), you could have that written in C++ into the DLL Scriptor's common code. This is basicly how FE's portals are working, the code is in the base C++ code for the scriptor.

I like the scriptor's linear fashion for SP missions. One thing I noticed when writting DLLs in C++ was it was in circle fashion, not linear. Basicly, every turn the DLL executes the execute() function which in turn does things. To write an SP mission, you would have to have alot of checks in your code to say is this done, is that done, is it time yet, can I get some cofee?. With the scriptor, everything in executed in a linear fashion.

Edit: Example of what you could add to the scriptor's base addObject() function to look for a "Rose Curse" than act upon it
// Perhaps a Rose Curse?
  if(strncmp(ODFName,"aprosec",7) == 0) {
    RoseConstructorCurse();
    AddToMessagesBox("Cursix: AIEEEEEE! Rose is casting a Curse!");
    if(fRandomNum <= 0.66f) { // Curse has targeted Players...
      for(i=0; i<MAX_TEAMS; i++) {
        hndPlayer=GetPlayerHandle(i);
        if(hndPlayer) { // We found a player
          if(fRandomNum < 0.6) {
            SetMaxHealth(hndPlayer,3000);
            SetCurHealth(hndPlayer,1);
            SetMaxAmmo(hndPlayer,100);
            SetCurAmmo(hndPlayer,0);
          } else { // Very LITTLE Chance of it helping you!
            SetMaxHealth(hndPlayer,9000);
            SetCurHealth(hndPlayer,9000);
            SetMaxAmmo(hndPlayer,12000);
            SetCurAmmo(hndPlayer,12000);
          }
        }
      }
    } else if(fRandomNum < 0.8f) { // Curse has targeted Recyclers...
      AddHealth(enemy_recycler, 3000);
      SelfDamage(recycler, 3000);
    } else if(fRandomNum <= 0.81f) { // Curse has targeted Recyclers...
      AddHealth(recycler, 3000);
      SelfDamage(enemy_recycler, 3000);
    } else if(fRandomNum < 0.85f) { // Er, what?
      AddToMessagesBox("Rose: Wha? *blush*");
      AddToMessagesBox("Cursix: Whew, Sonic kissed Rose, crisis averted.");
      AddToMessagesBox("Sonic: Can I get some asprin now?");
      AddToMessagesBox("Cursix: Sorry, all out.");
      AddToMessagesBox("Sonic: DAMNIT!");
    } else { // Curse has targeted MM...Oh hoot...
      char MMGenderThing[12], MMNameThing[12];
      if(fRandomNum2 <= 0.4f) {
        strncpy(MMGenderThing,"him",sizeof(MMGenderThing));
        strncpy(MMNameThing,"Maxwell",sizeof(MMNameThing));
      } else if(fRandomNum2 <= 0.8f) {
        strncpy(MMGenderThing,"her",sizeof(MMGenderThing));
        strncpy(MMNameThing,"Wendy",sizeof(MMNameThing));
      } else {
        strncpy(MMGenderThing,"it",sizeof(MMGenderThing));
        strncpy(MMNameThing,"MM",sizeof(MMNameThing));
      }
      AddToMessagesBox("Rose: That's odd...Nothing Happened.");
      _snprintf(TempBuff,sizeof(TempBuff),"Reality: %s has malleted Rose for cursing %s.",
        MMNameThing,MMGenderThing);
      AddToMessagesBox(TempBuff);
    }
    hndCleanCancel=h;
    bCleanCancel=true;
  }


FYI, my CleanUp Function that executes a turn later:
// Use this function to do cleanup activities. This is always exected last
// in the execute function.
void instantMission::CleanUp()
{
  // If a Cancel Pod was made, cleanup!
  if(bCleanCancel) {
    RemoveObject(hndCleanCancel);
    bCleanCancel=false;
  }
}
"Linux is user friendly...
...it's just very selective about who its friends are."

CmptrWz

Which is to say that the Scriptor takes the C++ circle and breaks it for you, so that you can ignore the fact it loops ;)